<template>
  <div >
    <van-form >
      <!-- 基本信息 -->
      <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
        <div class="blue_item" />
        <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">收入合同管理</span>
      </div>
      <van-field readonly required name="contractPlanType" :value="fromdata.incomeDataList[0].IT.contractPlanType" label-width="12em" label="签约方式(合同计划类型)：" />
      <van-field readonly name="paymentLimitTotal" :value="payeeList[payeeList.length-1].paymentLimit" label-width="11em" label="收款含税额度合计(元)：" />
      <van-field readonly name="paymentLimitTotal" :value="businessdata.incomePlanDeviation" label-width="17em" label="收入合同签约额与收入计划偏差(%)：" />
      <van-field readonly name="splitIncludedAmountTotal" :value="fromdata.incomeDataList[0].IT.splitIncludedAmountTotal" label-width="12em" label="合同计划金额(含税元)：" />
      <van-field readonly required name="itAmount" :value="businessdata.itAmount" label-width="11em" label="IT收入金额(含税元)：" />
      <van-field readonly required name="itUniversalAmount" :value="businessdata.itUniversalAmount" label-width="13em" label="IT通服收入金额(含税元)：" />
      <van-field readonly required name="contractNoMoney" :value="Number(itList[itList.length-1].splitNoAmount)+Number(ctList[ctList.length-1].splitNoAmount)" label-width="12em" label="合同计划金额(不含税元)：" />
      <van-field readonly required name="itNoAmount" :value="itList[itList.length-1].splitNoAmount" label-width="11em" label="IT收入金额(不含税元)：" />
      <van-field readonly required name="itUniversalNoAmount" :value="itUniversalNoAmount" label-width="13em" label="IT通服收入金额(不含税元)：" />
      <van-field readonly name="businessCreateDate" :value="businessdata.businessCreateDate" label-width="7em" label="商机录入时间：" />
      <van-field readonly name="busEntryDelayDays" :value="businessdata.busEntryDelayDays" label-width="15em" label="商机录入滞后合同解析时间天数：" />
      <van-field readonly name="rateProductImplantationOwn" :value="businessdata.rateProductImplantationOwn" label-width="8em" label="自有产品植入率：" />
      <van-field readonly name="rateProductImplantation" :value="businessdata.rateProductImplantation" label-width="8em" label="自研产品植入率：" />

      <!--    <van-field readonly required name="contractSerialNumber" :value="fromdata.incomeDataList[0].IT.contractSerialNumber" label-width="6em" label="合同流水号：" />-->
      <!--    <van-field readonly name="contractNumber" :value="businessdata.contractNumber" label-width="5em" label="合同编码：" />-->
      <!--    <van-field readonly required name="contractAmount" :value="businessdata.contractAmount" label-width="10em" label="合同含税总金额(元)：" />-->
      <!--    <van-field readonly name="splitIncludedAmountTotal" :value="Number(itList[itList.length-1].splitIncludedAmount)+Number(ctList[ctList.length-1].splitIncludedAmount)" label-width="11em" label="合同计划金额(含税元)：" />-->
      <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
        <div class="blue_item" />
        <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">合同费项表</span>
      </div>
      <el-table :data="feeList" border style="width: 100%">
        <el-table-column prop="feeItemSerialNumber" label="费项序列号" />
        <el-table-column prop="feeItemsName" label="价款费项名称" />
        <el-table-column prop="feeItemsDescribe" label="费项描述" />
        <el-table-column prop="taxRate" label="税率" />
        <el-table-column prop="noAmount" label="不含税金额" width="120"/>
        <el-table-column prop="amount" label="含税金额"  width="120"/>
        <el-table-column prop="taxAmount" label="税额" />
      </el-table>

      <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
        <div class="blue_item" />
        <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">交付进度</span>
      </div>
      <el-table :data="fromdata.incomeDataList[0].IT.deliveryList" border style="width: 100%">
        <el-table-column prop="deliveryPhase" label="交付阶段" />
        <el-table-column prop="contractPartType" label="产品类型" />
        <el-table-column prop="contractSchedule" label="合同正文进度条款" />
        <el-table-column prop="deliveryDate" label="合同计划交付年月" />
        <el-table-column prop="contractDeadline" label="合同工期要求(天)" />
        <el-table-column prop="rests" label="其他" />
      </el-table>
      <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
        <div class="blue_item" />
        <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">收款计划</span>
      </div>
      <el-table :data="payeeList" border style="width: 100%">
        <el-table-column prop="paymentStage" label="收付款阶段" />
        <el-table-column prop="contractPartType" label="产品类型" />
        <el-table-column prop="paymentRatio" label="收付款比例(%)" />
        <el-table-column prop="paymentLimit" label="含税收付款额度(元)" width="120"/>
        <el-table-column prop="contractTerms" label="合同正文收付款条款" />
        <el-table-column prop="advanceDate" label="预计收付款年月" />
        <el-table-column prop="rests" label="其他" />
      </el-table>
      <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
        <div class="blue_item" />
        <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">拆分信息-IT部分</span>
      </div>
      <el-table :data="itList" border style="width: 100%">
        <el-table-column prop="feeItemsName" label="价款费项名称" />
        <el-table-column prop="splitBusinessType" label="业务大类" />
        <el-table-column prop="splitSujectName" label="账单名称" />
        <el-table-column prop="splitSujectCode" label="账单代码" />
        <el-table-column prop="isUniversal" label="是否属于通服收入" />
        <el-table-column prop="splitTaxRate" label="税率" />
        <el-table-column prop="splitIncludedAmount" label="含税总金额（元）" width="120"/>
        <el-table-column prop="splitNoAmount" label="不含税金额（元）" width="120"/>
        <el-table-column prop="splitTaxAmount" label="税额" />
        <el-table-column prop="paymentType" label="出账类型" />
        <el-table-column prop="billingTime" label="计费时长(月)" />
        <el-table-column prop="splitStartDate" label="预计计费起始日期" />
        <el-table-column prop="splitEndDate" label="预计计费结束日期" />
        <el-table-column prop="contractPhase" label="合同约定计费阶段" />
        <el-table-column prop="isAbilityLogo" label="是否融自有能力" />
        <el-table-column prop="entrustedSalesAccount" label="是否受托代销科目" />
      </el-table>
      <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
        <div class="blue_item" />
        <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">拆分信息-CT部分</span>
      </div>
      <el-table :data="ctList" border style="width: 100%">
        <el-table-column prop="feeItemsName" label="价款费项名称" />
        <el-table-column prop="splitBusinessType" label="业务大类" />
        <el-table-column prop="splitSujectName" label="账单名称" />
        <el-table-column prop="splitSujectCode" label="账单代码" />
        <el-table-column prop="isUniversal" label="是否属于通服收入" />
        <el-table-column prop="splitTaxRate" label="税率" />
        <el-table-column prop="splitIncludedAmount" label="含税总金额（元）" width="120"/>
        <el-table-column prop="splitNoAmount" label="不含税金额（元）" width="120"/>
        <el-table-column prop="splitTaxAmount" label="税额" />
        <el-table-column prop="paymentType" label="出账类型" />
        <el-table-column prop="billingTime" label="计费时长(月)" />
        <el-table-column prop="splitStartDate" label="预计计费起始日期" />
        <el-table-column prop="splitEndDate" label="预计计费结束日期" />
        <el-table-column prop="contractPhase" label="合同约定计费阶段" />
        <el-table-column prop="isAbilityLogo" label="是否融自有能力" />
        <el-table-column prop="entrustedSalesAccount" label="是否受托代销科目" />
      </el-table>
    </van-form>
    <div style="padding-bottom: 42px"></div>
  </div>
</template>
 
<script>
import { openFileUrl } from '@/store/openFile'
import historyAndSuggs from "@/views/srqr/historyAndSuggs.vue"
export default {
  data() {
    return {
      showUpAndDownPop:false, 
      UpAndDownPopColumns:['是', '否'],
      showCalculateModePop:false, 
      CalculateModePopColumns:['主理人', '代理人'],
      showIsAttentionPop:false, 
      IsAttentionPopColumns:['是', '否'],
      incomeDataList:{},
      itList:[],
      ctList:[],
      payeeList:[],
      itUniversalNoAmount:0,
      feeList:[]
    }
  },
  props: ['businessdata','fromdata','showHistory','historydata','approveList'],
  created() {
    this.incomeDataList=this.fromdata.incomeDataList[0].IT
    this.setdata()
  },
  methods: {
    setdata(){
      var feeItemsList_number1=0
      var feeItemsList_number2=0
      var feeItemsList_number3=0
      for (var i=0;i<this.incomeDataList.feeItemsList.length;i++) {
        feeItemsList_number1=Number(feeItemsList_number1)+Number(this.incomeDataList.feeItemsList[i].noAmount)
        feeItemsList_number2=Number(feeItemsList_number2)+Number(this.incomeDataList.feeItemsList[i].amount)
        feeItemsList_number3=Number(feeItemsList_number3)+Number(this.incomeDataList.feeItemsList[i].taxAmount)
        this.feeList.push(this.incomeDataList.feeItemsList[i]);
      }
      var feeItemsListadd={'feeItemSerialNumber':'合计','noAmount':feeItemsList_number1.toFixed(2), 'amount':feeItemsList_number2.toFixed(2),'taxAmount':feeItemsList_number3.toFixed(2)}
      this.feeList.push(feeItemsListadd);

      var itList_number1=0
      var itList_number2=0
      var itList_number3=0
      var ctList_number1=0
      var ctList_number2=0
      var ctList_number3=0
      var ctAndIt_number1=0
      var ctAndIt_number2=0
      var ctAndIt_number3=0
      for (var i=0;i<this.incomeDataList.splitList.length;i++) {
        if(this.incomeDataList.splitList[i].contractPartType=='IT'){
          itList_number1=Number(itList_number1)+Number(this.incomeDataList.splitList[i].splitIncludedAmount)
          itList_number2=Number(itList_number2)+Number(this.incomeDataList.splitList[i].splitNoAmount)
          itList_number3=Number(itList_number3)+Number(this.incomeDataList.splitList[i].splitTaxAmount)
          if(this.incomeDataList.splitList[i].isUniversal == "是"){
            this.itUniversalNoAmount = Number(this.incomeDataList.splitList[i].splitNoAmount)+ this.itUniversalNoAmount;
          }
          this.itList.push(this.incomeDataList.splitList[i]);
        }else{
          ctList_number1=Number(ctList_number1)+Number(this.incomeDataList.splitList[i].splitIncludedAmount)
          ctList_number2=Number(ctList_number2)+Number(this.incomeDataList.splitList[i].splitNoAmount)
          ctList_number3=Number(ctList_number3)+Number(this.incomeDataList.splitList[i].splitTaxAmount)
          this.ctList.push(this.incomeDataList.splitList[i]);
        }
        ctAndIt_number1=Number(ctAndIt_number1)+Number(this.incomeDataList.splitList[i].splitIncludedAmount)
        ctAndIt_number2=Number(ctAndIt_number2)+Number(this.incomeDataList.splitList[i].splitNoAmount)
        ctAndIt_number3=Number(ctAndIt_number3)+Number(this.incomeDataList.splitList[i].splitTaxAmount)
      }
      var ctAndItListadd={'feeItemsName':'IT+CT合计','splitIncludedAmount':ctAndIt_number1.toFixed(2), 'splitNoAmount':ctAndIt_number2.toFixed(2), 'splitTaxAmount':ctAndIt_number3.toFixed(2)}
      var itListadd={'feeItemsName':'合计','splitIncludedAmount':itList_number1.toFixed(2), 'splitNoAmount':itList_number2.toFixed(2), 'splitTaxAmount':itList_number3.toFixed(2)}
      this.itList.push(itListadd);
      this.itList.push(ctAndItListadd);
      var ctListadd={'feeItemsName':'合计','splitIncludedAmount':ctList_number1.toFixed(2), 'splitNoAmount':ctList_number2.toFixed(2), 'splitTaxAmount':ctList_number3.toFixed(2)}
      this.ctList.push(ctListadd);
      this.ctList.push(ctAndItListadd);
      var payeeList_number1=0
      var payeeList_number2=0
      for (var i=0;i<this.incomeDataList.payeeList.length;i++) {
        payeeList_number1=Number(payeeList_number1)+Number(this.incomeDataList.payeeList[i].paymentRatio)
        payeeList_number2=Number(payeeList_number2)+Number(this.incomeDataList.payeeList[i].paymentLimit)
        this.payeeList.push(this.incomeDataList.payeeList[i]);
      }
      var payeeListadd={'paymentStage':'合计','paymentRatio':payeeList_number1.toFixed(2), 'paymentLimit':payeeList_number2.toFixed(2)}
      this.payeeList.push(payeeListadd);
    },
    openFileUrlfun(value) {
      this.$router.push(
          {
            name: 'fileview',
            query: {
              openFileUrl: openFileUrl(value)
            }
          }
      );
    },
  },
  computed: {
    isCWSPLocation: function () {
      return this.location=='dict.accountingApproval'
    },
  },
  components: {
    historyAndSuggs
  },
}
</script>
 
<style>
.tables.el-table .cell {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-break: break-all;
    line-height: 15px;
    padding-left: 5px;
    padding-right: 5px;
}
</style>